--- Boss Health HUD
--- by EeveeEuphoria

--[[ GOALS:
    - Create a simple library that uses a provided NPC ID to generate boss health bars.
    - This *MUST* allow for multiple health bars for mutliple bosses in levels, do this first and foremost so that things don't get complicated later.
    - The health "bar" uses icons for amount of damage taken, ala the SMB2 health indicators.
    - Take into account bosses that have negative hit points, that's the custom values set by npc-n.txt.
        - Total should be like, 3 hits for most bosses? Use absolute values to add the two together.
]]

--[[ A DIFFERENT IDEA:
    - A system that briefly shows an enemy's health when they're hit, it fades away after a brief period of time.
        - Could easily use textplus to achieve this, especially if I use a hacky method.
        - Can either display numbers + health icon, or just health icons.
]]

--[[ TODO:
    - Create list for default health values
]]

local bosshpHUD = {}

local bossTable = {}


function bosshpHUD.onInitAPI()
    registerEvent(bosshpHUD, "onStart")
	registerEvent(bosshpHUD, "onDraw")
	registerEvent(bosshpHUD, "onTick")
end

function bosshpHUD.addBossID(id, section, health)
    local bossToAdd = {}
    bossToAdd.id = id
    bossToAdd.section = section
    bossToAdd.defaulthp = health

    table.insert(bossTable, bossToAdd)
    return bossToAdd
end


function bosshpHUD.onStart()
end


-- Get active NPCs by seeing if they're in the camera bounds
function bosshpHUD.onTick()
    for key, value in pairs(bossTable) do
        local TableThing = NPC.get(value.id, value.section)
        for key2, value2 in pairs(TableThing) do -- inception
            Text.print("ID: " .. tostring(value.id), 20, 220)
            Text.print("Despawn timer: " .. tostring(value2.despawnTimer), 20, 240)
            Text.print("Hits taken: " .. value2:mem(0x148, FIELD_FLOAT), 20, 260)
            Text.print("Default HP: " .. value.defaulthp, 20, 280)
        end
    end
end




return bosshpHUD